package com.gl.course1;

import java.util.concurrent.CountDownLatch;

/**
 * Created by GAOLEI on 2019/7/26.
 */
public class Foo {

    CountDownLatch latch1  = new CountDownLatch(1);
    CountDownLatch latch2  = new CountDownLatch(1);

    public Foo() {

    }

    public void first(Runnable printFirst) throws InterruptedException {
        latch1.countDown();
        // printFirst.run() outputs "first". Do not change or remove this line.
        printFirst.run();
    }

    public void second(Runnable printSecond) throws InterruptedException {
        latch1.await();
        latch2.countDown();
        // printSecond.run() outputs "second". Do not change or remove this line.
        printSecond.run();
    }

    public void third(Runnable printThird) throws InterruptedException {
        latch2.await();
        // printThird.run() outputs "third". Do not change or remove this line.
        printThird.run();
    }
}
